home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_gen / freeli10.zip / FREELIB.DOC < prev    next >
Text File  |  1996-04-22  |  50KB  |  1,698 lines

  1. ----------------------------------------------------------------------
  2. ------------ FREELIB: The FREE Assembly Language Library -------------
  3. --------------- Copyright (C) April 1996 Tenie Remmel ----------------
  4. ----------------------------------------------------------------------
  5.  
  6. 1. Introduction ................................ Line 15
  7. 2. Terms of use/Legal disclaimer ............... Line 34
  8. 3. Processors, calling conventions ............. Line 55
  9. 4. Re-assembling ............................... Line 91
  10. 5. Program Syntax .............................. Line 116
  11. 6. Procedure Reference ......................... Line 176
  12. 7. Future additions, bug reporting ............. Line 1652
  13.     
  14.  
  15. 1.  Introduction.
  16.  
  17.   FREELIB is a library of 130 procedures that may be useful for
  18.   programming in assembly language.   As the name implies, this
  19.   is public domain, completely free for all non-commercial use.
  20.   If you find this library useful,  you are strongly encouraged
  21.   to contribute some of your own routines for possible addition
  22.   to FREELIB.  Full source code is included, so if you find any
  23.   bugs (!)  or wish to make changes to any of the routines, you
  24.   can.  However, if you do make any improvements, please notify
  25.   the author,  so that FREELIB  can continue to be expanded and
  26.   improved. If you modify any part of this library, you may not
  27.   distribute it, for free or not, without prior permission from
  28.   the author (see below).
  29.  
  30.   Be sure to read the sections 2, 3 and 5 carefully,  including
  31.   the miscellaneous notes in section 3.
  32.  
  33.  
  34. 2.  Terms of use/Legal disclaimer.
  35.  
  36.   This software is hereby released into the public domain,  and
  37.   may  therefore  be freely  copied and distributed  within the
  38.   following restrictions: 
  39.  
  40.       1).  It is distributed in its original,  unmodified form,
  41.            including all source code and documentation.
  42.  
  43.       2).  No fee is charged for use, copying or distribution.
  44.  
  45.       3).  The program may not be  included with other goods or
  46.            services supplied for a fee, unless specific written
  47.            permission to do so is obtained  in advance from the
  48.            author.  (E-mail: tjr19@mail.nwlink.com)
  49.  
  50.   This program is provided AS-IS without any warranty,  express
  51.   or implied, including  but not limited to warranty of fitness
  52.   for a particular purpose.
  53.  
  54.  
  55. 3.  Processors, calling conventions, string type, etc.
  56.  
  57.   FREELIB is programmed in 80186 assembly language.  This is to
  58.   ensure compatibility with as many computers as possible,  but
  59.   not sacrificing very much speed.
  60.  
  61.   FREELIB uses the  Pascal calling convention.   The parameters
  62.   are  pushed on the stack in order,  and the calling procedure
  63.   does not have to worry about stack cleanup.  This seems to be
  64.   the fastest method,  and it also helps in debugging... if the
  65.   wrong number of arguments are pushed to call a procedure, the
  66.   program will crash, which is much more obvious than the weird
  67.   results produced with the 'C' convention, etc.
  68.  
  69.   Notice that in the source code,  the syntax is given by a 'C'
  70.   style prototype.  Why a 'C' prototype?  Well, Pascal does not
  71.   have prototypes, and the 'C' prototype is useful to concisely
  72.   show the syntax of a procedure on one line.
  73.  
  74.   Misc. Notes:   Many of the routines assume  DS = CS,  so make
  75.   sure that this is the case.   The program is intended to be a
  76.   .COM file, but .EXE files are possible as long as the DS = CS
  77.   restriction is met.   Do not use uninitialized data,  it will
  78.   confuse the memory manager.  Use dynamically allocated memory
  79.   instead.  The fixed-point numbers are 16:16, and signed.  The
  80.   strings are ASCIIZ (null-terminated) strings, like in C.  The
  81.   long integers can be either signed or unsigned,  depending on
  82.   which multiply, divide and shift you use.  When clock timings
  83.   are given,  they always include the call/return,  and exclude
  84.   the argument pushes.   Even though some  procedures require a
  85.   character argument,  a word-sized value must still be pushed.
  86.   There is no way to push a byte value.   The files TEXT???.INC
  87.   are not to be included in your programs.  They are internally
  88.   used by the High-Res Text Mode routines in FREELIB3.ASX.  The
  89.   colorset in High-Res Text Mode is different, see below.
  90.  
  91.   Colorset in High-Res Text Mode:
  92.  
  93.   0 = Black         8 = Dark Gray
  94.   1 = Dark Green    9 = Red
  95.   2 = Green         10 = Orange
  96.   3 = Light Green   11 = Yellow
  97.   4 = True Blue     12 = Sky Blue
  98.   5 = Dark Purple   13 = Dark Blue
  99.   6 = Magenta       14 = Cyan
  100.   7 = Light Gray    15 = White
  101.  
  102.  
  103. 4.  Re-assembling FREELIB.
  104.  
  105.   A batch file (REDO.BAT) is provided for this purpose.   These
  106.   source files are .ASX files (ASsembly eXtended) which contain
  107.   multiple modules.  A utility (SPLIT.COM) is included to split
  108.   the .ASX files.  SPLIT.C is the 'C' source to SPLIT.COM.  The
  109.   batch file takes care of splitting the files. However, if you
  110.   wish to add a new .ASX file  (in addition to FREELIB1-3), you
  111.   must modify the batch file, otherwise it will be ignored.
  112.  
  113.   SPLIT outputs TLIB  command file codes.   SPLIT takes zero or
  114.   one arguments.  When run with no arguments, it produces codes
  115.   that end the command file.   When run with an argument  (what
  116.   it is doesn't matter)  it produces codes that continue to the
  117.   next file.
  118.  
  119.   In the .ASX files, a line starting with three tildes (~) that
  120.   are followed by a file name without extension will denote the
  121.   beginning of a new module.   Either make sure that all of the
  122.   module names start with 'C_' or modify the REDO.BAT file.  If
  123.   you put any .ASM  files with names starting with  'C_' in the
  124.   FREELIB directory, be warned: they will be deleted along with
  125.   the temporary .ASM files created by SPLIT.
  126.  
  127.  
  128. 5.  Program syntax for use with FREELIB.
  129.  
  130.   Your program should do a near call, or jump, to the 'startup'
  131.   procedure at the beginning. The main body of the program must
  132.   be in the procedure 'main', which must be declared public.
  133.  
  134.   On entry to main, the number of arguments is in CX and a list
  135.   of near pointers to the arguments is at offset DI.  DS and ES
  136.   both equal CS.  AX, BX, DX, SI, and BP are undefined.
  137.  
  138.   You must declare as  external all procedures  that you intend
  139.   to use.  One way to simplify this is with a macro:
  140.   
  141. ;**************************************
  142.  
  143. Macro       lcall prced             ;; library call
  144.  
  145.             extrn prced:near        ;; declare as external
  146.             call prced              ;; call procedure
  147.  
  148. EndM
  149.  
  150. ;**************************************
  151.  
  152.   and then you would replace  'call' with  'lcall' when calling
  153.   library procedures.
  154.  
  155.   This is a skeleton program:
  156.  
  157. ;**************************************
  158.  
  159. Ideal                               ; ideal mode
  160.  
  161. Public      main                    ; declare main as public
  162. Extrn       startup:near            ; declare startup procedure
  163.  
  164. Macro       lcall prced             ;; library call
  165.  
  166.             extrn prced:near        ;; declare as external
  167.             call prced              ;; call procedure
  168.  
  169. EndM
  170.  
  171. Model Tiny                          ; tiny model
  172. CodeSeg                             ; code segment
  173. Org 100h                            ; .COM file start
  174.  
  175. Start:      jmp startup             ; start up program
  176.  
  177. Proc        main                    ; main procedure
  178.  
  179.             ret                     ; return
  180.  
  181. EndP        main
  182.  
  183. End Start                           ; entry at 'Start'
  184.  
  185. ;**************************************
  186.  
  187.  
  188. 6.  Reference: Syntax and description of all FREELIB procedures.
  189.  
  190.   -------------------------------------------------------------
  191.   ------------ Initialization and Exit Procedures -------------
  192.   -------------------------------------------------------------
  193.  
  194.   ---------- startup            Start program
  195.  
  196.     jmp startup
  197.  
  198.     This procedure must be jumped to at the beginning of
  199.     your program.  (See Section 5.)
  200.  
  201.     This procedure calls 'main'.  It also does internal
  202.     initialization, and sets null Ctrl-C and divide-error
  203.     handlers.
  204.  
  205.   ---------- exit               Exit program
  206.  
  207.     push retcode
  208.     call exit
  209.  
  210.     This procedure exits your program with a return code.
  211.     If exit is not used, the return code is the value of
  212.     AX on return from main.
  213.  
  214.   -------------------------------------------------------------
  215.   ---------------------- File Procedures ----------------------
  216.   -------------------------------------------------------------
  217.  
  218.   ---------- fopen              Open file
  219.  
  220.     push offset filename
  221.     push filemode
  222.     call fopen
  223.     ; AX = handle
  224.     
  225.     This procedure opens a buffered file.  The handle is
  226.     returned in AX.  This handle is NOT a DOS handle.
  227.     If it is used as such, the results are unpredictable.
  228.    
  229.     The file modes are:
  230.     
  231.     0     Open for Read-Only (open if it exists, fail if not)
  232.     1     Modify for Read/Write (open if it exists, create if not)
  233.     2     Open for Read/Write (open if it exists, fail if not)
  234.     3     Create for Read/Write (truncate if it exists, create if not)
  235.  
  236.   ---------- fclose             Close file
  237.  
  238.     push handle
  239.     call fclose
  240.  
  241.     This procedure closes a buffered file.
  242.  
  243.   ---------- fgetc              Get char from file
  244.  
  245.     push handle
  246.     call fgetc
  247.     ; AX = char
  248.  
  249.     This procedure gets a character from a buffered file.
  250.     If the end of file is reached or an error occurs, -1
  251.     is returned.
  252.  
  253.   ---------- fputc              Put char to file
  254.  
  255.     push handle
  256.     push char
  257.     call fputc
  258.     ; AX = return code
  259.  
  260.     This procedure puts a character to a buffered file.
  261.     If the end of file is reached or an error occurs, -1
  262.     is returned, otherwise the character is returned.
  263.  
  264.   ---------- fread              Read block from file
  265.  
  266.     push handle
  267.     push size
  268.     push offset buf
  269.     call fread
  270.     ; AX = return code
  271.  
  272.     This procedure reads a block from a buffered file.  The
  273.     number of characters read is returned.  If this is less
  274.     than the requested size, the end of file was reached or
  275.     an error occured.
  276.  
  277.   ---------- fwrite             Write block to file
  278.  
  279.     push handle
  280.     push size
  281.     push offset buf
  282.     call fwrite
  283.     ; AX = return code
  284.  
  285.     This procedure writes a block to a buffered file.  The
  286.     number of characters written is returned.  If this is
  287.     less than the requested size, an error occured.
  288.  
  289.   ---------- fseek              Set file pointer
  290.  
  291.     push handle
  292.     push pos_hi
  293.     push pos_lo
  294.     push mode
  295.     call fseek
  296.     ; AX = return code
  297.  
  298.     This procedure sets the position of the file pointer.
  299.     The position is a long integer.  If an error occurs, 0
  300.     is returned, otherwise a nonzero value is returned.
  301.  
  302.     The seek modes are:
  303.  
  304.     0     Seek from beginning of file
  305.     1     Seek from current position
  306.     2     Seek from end of file
  307.  
  308.   ---------- ftell              Get file pointer
  309.  
  310.     push handle
  311.     call ftell
  312.     ; DX:AX = file pointer
  313.  
  314.     This procedure returns the position of the file pointer.
  315.  
  316.   ---------- fsetbuf            Set file buffer size
  317.  
  318.     push size
  319.     call fsetbuf
  320.  
  321.     This procedure sets the file buffer size.  It does not
  322.     affect currently open files.  It only affects files that
  323.     are opened after this call.  The default size is 512
  324.     bytes, but it may be set to from 128 to 32752 bytes.
  325.     If the size requested is greater than 32768, the high
  326.     bit is simply masked off, f.i. 33024 will produce 256.
  327.  
  328.   ---------- ftrunc             Truncate file
  329.  
  330.     push handle
  331.     call ftrunc
  332.     ; AX = return code
  333.  
  334.     This procedure truncates a buffered file at the current
  335.     position.  If an error occurs, 0 is returned, otherwise
  336.     a nonzero value is returned.
  337.  
  338.   ---------- fdel               Delete file
  339.  
  340.     push offset filename
  341.     call fdel
  342.     ; AX = return code
  343.  
  344.     This procedure deletes a file.  If an error occurs, 0 is
  345.     returned, otherwise a nonzero value is returned.
  346.     
  347.   ---------- fmove              Move/Rename file
  348.  
  349.     push offset oldname
  350.     push offset newname
  351.     call fmove
  352.     ; AX = return code
  353.  
  354.     This procedure moves and/or renames a file.  If an error
  355.     occurs, 0 is returned, otherwise a nonzero value is
  356.     returned.
  357.  
  358.   -------------------------------------------------------------
  359.   --------------- Directory and Disk Procedures ---------------
  360.   -------------------------------------------------------------
  361.  
  362.   ---------- mkdir              Create Directory
  363.  
  364.     push offset dirname
  365.     call mkdir
  366.     ; AX = return code
  367.  
  368.     This procedure creates a directory.  If an error occurs,
  369.     0 is returned, otherwise a nonzero value is returned.
  370.     
  371.   ---------- rmdir              Remove Directory
  372.  
  373.     push offset dirname
  374.     call rmdir
  375.     ; AX = return code
  376.  
  377.     This procedure deletes a directory.  If an error occurs,
  378.     0 is returned, otherwise a nonzero value is returned.
  379.     
  380.   ---------- setdir             Set Current Directory
  381.  
  382.     push offset dirname
  383.     call setdir
  384.     ; AX = return code
  385.  
  386.     This procedure sets the current directory.  If an error
  387.     occurs, 0 is returned, otherwise a nonzero value is
  388.     returned.
  389.     
  390.   ---------- getdir             Get Current Directory
  391.  
  392.     push offset buffer
  393.     call getdir
  394.  
  395.     This procedure returns the current directory.
  396.     The full path is returned in 'buffer'.
  397.     
  398.   ---------- setdrive           Set Current Drive
  399.  
  400.     push dr_num
  401.     call setdrive
  402.  
  403.     This procedure sets the current drive.  The numbers are
  404.     the same as the DOS drive numbers.  (0 = default, 1 = A,
  405.     2 = B, 3 = C, etc.)
  406.     
  407.   ---------- getdrive           Get Current Drive
  408.  
  409.     call getdrive
  410.     ; AX = drive number
  411.  
  412.     This procedure returns the current drive.  The numbers
  413.     are the same as the DOS drive numbers.  (0 = default,
  414.     1 = A, 2 = B, 3 = C, etc.)
  415.     
  416.   ---------- getdfree           Get Free Disk Space
  417.  
  418.     push dr_num
  419.     call getdfree
  420.     ; DX:AX = amount of free space
  421.  
  422.     This procedure returns the amount of free disk space
  423.     on a drive.  The number returned is in bytes.
  424.     
  425.  
  426.   -------------------------------------------------------------
  427.   ----------------- Memory Manager Procedures -----------------
  428.   -------------------------------------------------------------
  429.  
  430.   ---------- allocmem           Allocate Memory
  431.  
  432.     push size
  433.     call allocmem
  434.     ; AX = pointer
  435.  
  436.     This procedure allocates memory.  If there was not a big
  437.     enough block of memory, -1 is returned, otherwise a
  438.     pointer to the block of memory is returned.
  439.  
  440.   ---------- freemem            Free Memory
  441.  
  442.     push ptr
  443.     call freemem
  444.  
  445.     This procedure frees memory.  If 'ptr' does not point to
  446.     a valid block, nothing happens.  If free blocks abut the
  447.     block to be freed, they are coalesced.
  448.  
  449.   ---------- getmfree           Get Free Memory
  450.  
  451.     call getmfree
  452.     ; AX = size of largest free block
  453.  
  454.     This procedure returns the size of the largest free
  455.     block of memory.  If there are no free blocks, 0 is
  456.     returned.
  457.  
  458.   ---------- faralloc           Allocate Far Memory
  459.  
  460.     push size
  461.     call faralloc
  462.     ; AX = segment
  463.  
  464.     This procedure allocates far memory.  If there was not
  465.     a big enough block of memory, -1 is returned, otherwise
  466.     the segment of the memory block is returned.  The size
  467.     must be specified in paragraphs (16 bytes each).  This
  468.     calls the DOS allocate memory service.
  469.  
  470.   ---------- farfree            Free Far Memory
  471.  
  472.     push seg
  473.     call freemem
  474.  
  475.     This procedure frees far memory.  If 'seg' is not the
  476.     segment of a valid memory block, the results will be
  477.     undefined.  If free blocks abut the block to be freed,
  478.     they are coalesced.  This calls the DOS free memory
  479.     service.
  480.  
  481.   ---------- getfarfree         Get Free Far Memory
  482.  
  483.     call getfarfree
  484.     ; AX = size of largest free block
  485.  
  486.     This procedure returns the size of the largest free
  487.     block of far memory.  If there are no free blocks, 0
  488.     is returned.
  489.  
  490.  
  491.   -------------------------------------------------------------
  492.   ----------------- Put/Get String Procedures -----------------
  493.   -------------------------------------------------------------
  494.  
  495.   ---------- puts               Put String
  496.  
  497.     push offset string
  498.     call puts
  499.  
  500.     This procedure writes a string to the screen.  If the
  501.     STDOUT handle is redirected, this still works.  The
  502.     string is output literally, using Int 29h.
  503.  
  504.   ---------- fputs              Put String to File
  505.  
  506.     push handle
  507.     push offset string
  508.     call fputs
  509.  
  510.     This procedure writes a string to a file.  If an error
  511.     occurs, -1 is returned, otherwise a nonzero value is
  512.     returned.  The handle is a FREELIB handle, not a DOS
  513.     handle.
  514.  
  515.   ---------- xputs              Put String, Generalized
  516.  
  517.     push offset outfunc
  518.     push offset string
  519.     call xputs
  520.  
  521.     This procedure outputs a string using a user-defined
  522.     function.  The function must take one word argument,
  523.     the character to output, save all registers, and return
  524.     with a 'Ret 2' to clean up the stack.
  525.  
  526.   ---------- gets               Get String
  527.  
  528.     push offset buffer
  529.     push max
  530.     call gets
  531.  
  532.     This procedure inputs a string from the keyboard.  The
  533.     string of maximum 'max' chars will be put into 'buffer'.
  534.     Any excess characters will be discarded.  This procedure
  535.     allows simple editing using the <BkSp> key.
  536.  
  537.   ---------- fgets              Get String from File
  538.  
  539.     push handle
  540.     push offset buffer
  541.     push max
  542.     call fgets
  543.  
  544.     This procedure reads a line from a file.  The string of
  545.     maximum 'max' chars will be read into 'buffer'.  The
  546.     line must end with a CR/LF pair.  An entire line will be
  547.     input even if it exceeds 'max' characters.  Any excess
  548.     will be discarded.  The handle is a FREELIB handle, not
  549.     a DOS handle.
  550.  
  551.   ---------- xgets              Get String, Generalized
  552.  
  553.     push offset outfunc
  554.     push offset buffer
  555.     push max
  556.     push terminator
  557.     call xgets
  558.  
  559.     This procedure reads a logical line using a user-defined
  560.     function.  The function must take zero arguments and
  561.     return in AL the character input.  No register except
  562.     AX may be changed.  The value 'terminator' must be
  563.     returned on end of logical line.  The string of maximum
  564.     'max' chars will be read into 'buffer'.  An entire
  565.     logical line will be input even if it exceeds 'max'
  566.     characters.  Any excess will be discarded.
  567.  
  568.  
  569.   -------------------------------------------------------------
  570.   ------------- Formatted String Print Procedures -------------
  571.   -------------------------------------------------------------
  572.  
  573.   ---------- printf             Print Formatted String
  574.  
  575.     push offset fmtstr
  576.     push offset arglist
  577.     call printf
  578.  
  579.     This procedure prints a formatted string to the screen.
  580.     It is similar to the 'printf()' in 'C'.  In the format
  581.     string, the '%' character is special.  The '%' character
  582.     can be followed by the following characters, which
  583.     indicate what type of argument to print:
  584.  
  585.       %d        Integer
  586.       %x        Hex integer
  587.       %s        String
  588.       %c        Character
  589.       %ld       Long integer
  590.       %lx       Long hex integer
  591.  
  592.     The parameter 'arglist' is a list of arguments, in
  593.     order.  Their types are taken from the format string.
  594.     If the wrong type is specified in the format string,
  595.     printf has no way of knowing, so the results will be
  596.     unpredictable.
  597.  
  598.     Example of using printf:
  599.  
  600. ;**************************************
  601.  
  602.             ...
  603.  
  604. FmtStr      db '%d %s %c %lx',0
  605.  
  606. ArgList     dw 15600
  607.             db 'This is a string',0
  608.             db 'X'
  609.             dd 1A2B3C4Dh
  610.  
  611.             ...
  612.  
  613.             push offset FmtStr
  614.             push offset ArgList
  615.             call printf
  616.  
  617.             ...
  618.  
  619. ;**************************************
  620.  
  621.     This example will output '15600 This is a string X 1A2B3C4D'.
  622.  
  623.   ---------- fprintf            Print Formatted String to File
  624.  
  625.     push handle
  626.     push offset fmtstr
  627.     push offset arglist
  628.     call printf
  629.  
  630.     This procedure prints a formatted string to a file.  It
  631.     works the same way printf does.  See 'printf' for more
  632.     information.
  633.  
  634.   ---------- sprintf            Print Formatted String to String
  635.  
  636.     push offset dest_str
  637.     push offset fmtstr
  638.     push offset arglist
  639.     call printf
  640.  
  641.     This procedure prints a formatted string to a string.
  642.     The string output will be null terminated.  This
  643.     procedure works the same way printf does.  See 'printf'
  644.     for more information.
  645.  
  646.   ---------- xprintf            Print Formatted String, Generalized
  647.  
  648.     push offset outfunc
  649.     push offset fmtstr
  650.     push offset arglist
  651.     call printf
  652.  
  653.     This procedure prints a formatted string using a user
  654.     defined function.  The function must take one word
  655.     argument, the character to output, save all registers,
  656.     and return with a 'Ret 2' to clean up the stack.  This
  657.     procedure works the same way printf does.  See 'printf'
  658.     for more information.
  659.  
  660.  
  661.   -------------------------------------------------------------
  662.   ------------ Alphanumeric Conversion Procedures -------------
  663.   -------------------------------------------------------------
  664.  
  665.   ---------- atoi               Convert String to Integer
  666.  
  667.     push offset string
  668.     call atoi
  669.     ; AX = result
  670.  
  671.     This procedure converts a string to an integer.  It
  672.     recognizes the '-' and '+' signs, but it will stop on
  673.     any other non-digit.  The integer corresponding to the
  674.     string is returned.  If the result overflows, the low
  675.     16 bits of the result are returned.
  676.  
  677.   ---------- atol               Convert String to Long
  678.  
  679.     push offset string
  680.     call atol
  681.     ; DX:AX = result
  682.  
  683.     This procedure converts a string to a long integer.
  684.     It recognizes the '-' and '+' signs, but it will stop on
  685.     any other non-digit.  The long integer corresponding to
  686.     the string is returned.  If the result overflows, the
  687.     low 32 bits of the result are returned.
  688.  
  689.   ---------- itoa               Convert Integer to String
  690.  
  691.     push number
  692.     push offset buffer
  693.     call itoa
  694.  
  695.     This procedure converts an integer to a string.  On
  696.     return, 'buffer' will contain the decimal representation
  697.     of 'number'.  The string will be null terminated.  If
  698.     the number is negative, this will be handled correctly.
  699.  
  700.   ---------- ltoa               Convert Long to String
  701.  
  702.     push num_hi
  703.     push num_lo
  704.     push offset buffer
  705.     call ltoa
  706.  
  707.     This procedure converts a long integer to a string.  On
  708.     return, 'buffer' will contain the decimal representation
  709.     of the number.  The string will be null terminated.  If
  710.     the number is negative, this will be handled correctly.
  711.  
  712.   ---------- atofix             Convert String to Fixed-Point
  713.  
  714.     push offset string
  715.     call atofix
  716.     ; DX:AX = result
  717.  
  718.     This procedure converts a string to a fixed-point
  719.     number.  Itrecognizes the '-' and '+' signs and the
  720.     decimal point, but it will stop on any other non-digit.
  721.     The fixed-point number corresponding to the string is
  722.     returned.  If the result overflows, the value returned
  723.     will have the correct fractional part, and the integer
  724.     part will be the low 16 bits of the true value.
  725.  
  726.   ---------- fixtoa             Convert Fixed-Point to String
  727.  
  728.     push num_hi
  729.     push num_lo
  730.     push offset buffer
  731.     call fixtoa
  732.  
  733.     This procedure converts a fixed-point number to a
  734.     string.  On return, 'buffer' will contain the decimal
  735.     representation of the number.  The string will be null
  736.     terminated.  If the number is negative, this will be
  737.     handled correctly.  Fractions will also be handled
  738.     correctly.
  739.  
  740.  
  741.   -------------------------------------------------------------
  742.   ------ Long Integer/Fixed Point Arithmetic Procedures -------
  743.   -------------------------------------------------------------
  744.  
  745.   ---------- ldiv               Long Divide
  746.  
  747.     push num1_hi
  748.     push num1_lo
  749.     push num2_hi
  750.     push num2_lo
  751.     call ldiv
  752.     ; DX:AX = result
  753.  
  754.     This procedure divides unsigned long integers.
  755.     It divides 'num1' by 'num2'.
  756.  
  757.   ---------- lidiv              Long Divide, Signed
  758.  
  759.     push num1_hi
  760.     push num1_lo
  761.     push num2_hi
  762.     push num2_lo
  763.     call lidiv
  764.     ; DX:AX = result
  765.  
  766.     This procedure divides signed long integers.
  767.     It divides 'num1' by 'num2'.
  768.  
  769.   ---------- lmul               Long Multiply
  770.  
  771.     push num1_hi
  772.     push num1_lo
  773.     push num2_hi
  774.     push num2_lo
  775.     call lmul
  776.     ; DX:AX = result
  777.  
  778.     This procedure multiplies unsigned long integers.
  779.     It takes 70 clock ticks on a 486, including the
  780.     call/return but not the argument pushes.
  781.  
  782.   ---------- limul              Long Multiply, Signed
  783.  
  784.     push num1_hi
  785.     push num1_lo
  786.     push num2_hi
  787.     push num2_lo
  788.     call limul
  789.     ; DX:AX = result
  790.  
  791.     This procedure multiplies signed long integers.
  792.     It takes 89-97 clock ticks on a 486, including the
  793.     call/return but not the argument pushes.
  794.  
  795.   ---------- lshl               Long Shift Left
  796.  
  797.     push num_hi
  798.     push num_lo
  799.     push dist
  800.     call lshl
  801.     ; DX:AX = result
  802.  
  803.     This procedure shifts a long integer to the left.
  804.     It shifts 'num' by 'dist', and takes 37 clock
  805.     ticks on a 486, including the call/return but not
  806.     the argument pushes.
  807.  
  808.   ---------- lshr               Long Shift Right
  809.  
  810.     push num_hi
  811.     push num_lo
  812.     push dist
  813.     call lshr
  814.     ; DX:AX = result
  815.  
  816.     This procedure shifts an unsigned long integer to the
  817.     right.  It shifts 'num' by 'dist', and takes 37 clock
  818.     ticks on a 486, including the call/return but not
  819.     the argument pushes.
  820.  
  821.   ---------- lsar               Long Shift Right, Signed
  822.  
  823.     push num_hi
  824.     push num_lo
  825.     push dist
  826.     call lsar
  827.     ; DX:AX = result
  828.  
  829.     This procedure shifts a signed long integer to the
  830.     right.  It shifts 'num' by 'dist', and takes 39 clock
  831.     ticks on a 486, including the call/return but not
  832.     the argument pushes.
  833.  
  834.   ---------- fixmul             Fixed-Point Multiply
  835.  
  836.     push num1_hi
  837.     push num1_lo
  838.     push num2_hi
  839.     push num2_lo
  840.     call fixmul
  841.     ; DX:AX = result
  842.  
  843.     This procedure multiplies fixed-point numbers.
  844.     It takes 101-109 clock ticks on a 486, including
  845.     the call/return but not the argument pushes.
  846.  
  847.   ---------- fixdiv             Fixed-Point Divide
  848.  
  849.     push num1_hi
  850.     push num1_lo
  851.     push num2_hi
  852.     push num2_lo
  853.     call fixdiv
  854.     ; DX:AX = result
  855.  
  856.     This procedure divides fixed-point numbers.
  857.     It divides 'num1' by 'num2'.
  858.  
  859.  
  860.   -------------------------------------------------------------
  861.   ---------------------- String Procedures --------------------
  862.   -------------------------------------------------------------
  863.  
  864.   ---------- strlen             String Length
  865.  
  866.     push offset string
  867.     call strlen
  868.     ; AX = length
  869.  
  870.     This procedure returns the length of a string, not
  871.     including the null terminator.
  872.  
  873.   ---------- strcpy             Copy String
  874.  
  875.     push offset dest_str
  876.     push offset src_str
  877.     call strcpy
  878.  
  879.     This procedure copies 'src_str' to 'dest_str', including
  880.     the null terminator.  There is no checking to see if the
  881.     string fits, so be careful.
  882.  
  883.   ---------- strcat             Concatenate Strings
  884.  
  885.     push offset dest_str
  886.     push offset src_str
  887.     call strcat
  888.  
  889.     This procedure concatenates 'src_str' onto 'dest_str',
  890.     including the null terminator.  There is no checking to
  891.     see if the string fits, so be careful.
  892.  
  893.   ---------- strcmp             Compare Strings
  894.  
  895.     push offset string1
  896.     push offset string2
  897.     call strcmp
  898.     ; AX  = return value
  899.  
  900.     This procedure compares 'string1' and 'string2'.  If
  901.     'string2' is lexicographically greater, a negative value
  902.     is returned.  If 'string1' is greater, a positive value
  903.     is returned.  If they are equal, zero is returned.
  904.  
  905.   ---------- stricmp            Compare Strings, Case Insensitive
  906.  
  907.     push offset string1
  908.     push offset string2
  909.     call stricmp
  910.     ; AX  = return value
  911.  
  912.     This procedure compares 'string1' and 'string2'.  If
  913.     'string2' is lexicographically greater, a negative value
  914.     is returned.  If 'string1' is greater, a positive value
  915.     is returned.  If they are equal, zero is returned.  This
  916.     procedure differs from strcmp in that the compare is
  917.     case insensitive.
  918.  
  919.   ---------- strchr             Search String for Char
  920.  
  921.     push offset string
  922.     push char
  923.     call strchr
  924.     ; AX  = return value
  925.  
  926.     This procedure searches for 'char' in 'string'.  If the
  927.     character is not found, -1 is returned, otherwise the
  928.     position of the character in the string is returned.
  929.  
  930.   ---------- strstr             Search String for Substring
  931.  
  932.     push offset string
  933.     push offset substr
  934.     call strchr
  935.     ; AX  = return value
  936.  
  937.     This procedure searches for 'substr' in 'string'.  If
  938.     the substring is not found, -1 is returned, otherwise
  939.     the position of the substring in the main string is
  940.     returned.
  941.  
  942.   ---------- strlwr             Convert String to Lowercase
  943.  
  944.     push offset string
  945.     call strlwr
  946.  
  947.     This procedure converts a string to lowercase.  Any
  948.     character in the string that is already lowercase or
  949.     that is not a letter will not be affected.
  950.  
  951.   ---------- strupr             Convert String to Uppercase
  952.  
  953.     push offset string
  954.     call strupr
  955.  
  956.     This procedure converts a string to uppercase.  Any
  957.     character in the string that is already uppercase or
  958.     that is not a letter will not be affected.
  959.  
  960.   ---------- strltrim           Trim Leading Spaces
  961.  
  962.     push offset string
  963.     call strltrim
  964.  
  965.     This procedure trims leading spaces from a string.  If
  966.     there are no leading spaces, nothing happens.
  967.  
  968.   ---------- strrtrim           Trim Trailing Spaces
  969.  
  970.     push offset string
  971.     call strrtrim
  972.  
  973.     This procedure trims trailing spaces from a string.  If
  974.     there are no trailing spaces, nothing happens.
  975.  
  976.  
  977.   -------------------------------------------------------------
  978.   ------------------ Memory Block Procedures ------------------
  979.   -------------------------------------------------------------
  980.  
  981.   ---------- memcpy             Copy Memory Block
  982.  
  983.     push dest_offset
  984.     push src_offset
  985.     push length
  986.     call memcpy
  987.  
  988.     This procedure copies a block of memory from
  989.     'src_offset' to 'dest_offset'.  The block is of length
  990.     'length'.  This procedure will work correctly if the
  991.     blocks overlap.
  992.  
  993.   ---------- memset             Set Memory Block
  994.  
  995.     push memd_offset
  996.     push length
  997.     push byte
  998.     call memset
  999.  
  1000.     This procedure fills a block of memory of length
  1001.     'length' at 'mem_offset' with 'byte'.
  1002.  
  1003.   ---------- memcmp             Compare Memory Blocks
  1004.  
  1005.     push dest_offset
  1006.     push src_offset
  1007.     push length
  1008.     call memcmp
  1009.     ; AX = return code
  1010.  
  1011.     This procedure compares two blocks of memory at offsets
  1012.     'src_offset' and 'dest_offset'.  The blocks are of
  1013.     length 'length'.  If they are equal, 1 is returned,
  1014.     otherwise 0 is returned.
  1015.  
  1016.   ---------- memchr             Search Memory Block
  1017.  
  1018.     push mem_offset
  1019.     push length
  1020.     push byte
  1021.     call memchr
  1022.  
  1023.     This procedure searches a block of memory of length
  1024.     'length' at 'src_offset' for 'byte'.  If the byte is
  1025.     found, its position within the block is returned,
  1026.     otherwise -1 is returned.
  1027.  
  1028.  
  1029.   -------------------------------------------------------------
  1030.   ---------------- Search and Sort Procedures -----------------
  1031.   -------------------------------------------------------------
  1032.  
  1033.   ---------- isearch            Search Array of Integers
  1034.  
  1035.     push offset array
  1036.     push size
  1037.     push elem
  1038.     call isearch
  1039.     ; AX = return code
  1040.  
  1041.     This procedure searches an array of integers of size
  1042.     'size' for 'elem'.  This procedure assumes that the
  1043.     array is sorted.  If the element is found, its position
  1044.     in the array is returned, otherwise -1 is returned.
  1045.  
  1046.   ---------- lsearch            Search Array of Longs
  1047.  
  1048.     push offset array
  1049.     push size
  1050.     push elem_hi
  1051.     push elem_lo
  1052.     call lsearch
  1053.     ; AX = return code
  1054.  
  1055.     This procedure searches an array of long integers of
  1056.     size 'size' for 'elem'.  This procedure assumes that the
  1057.     array is sorted.  If the element is found, its position
  1058.     in the array is returned, otherwise -1 is returned.
  1059.  
  1060.   ---------- ssearch            Search Array of Strings
  1061.  
  1062.     push offset array
  1063.     push size
  1064.     push offset elem
  1065.     call ssearch
  1066.     ; AX = return code
  1067.  
  1068.     This procedure searches an array of strings of size
  1069.     'size' for 'elem'.  This procedure assumes that the
  1070.     array is sorted.  If the element is found, its position
  1071.     in the array is returned, otherwise -1 is returned.
  1072.  
  1073.   ---------- xsearch            Search Array, Generalized
  1074.  
  1075.     push offset array
  1076.     push size
  1077.     push offset elem
  1078.     push offset cmpfunc
  1079.     call xsearch
  1080.     ; AX = return code
  1081.  
  1082.     This procedure searches an array of pointers of size
  1083.     'size' for 'elem'.  It assumes that the array is sorted.
  1084.     If the element is found, its position in the array is
  1085.     returned, otherwise -1 is returned.
  1086.  
  1087.     This procedure uses a user-defined function.  The
  1088.     function must take two word-sized pointer arguments.
  1089.     It must return the result of the comparison in AX so
  1090.     that a negative value indicates less, a positive value
  1091.     indicates greater, and zero indicates equal, and it
  1092.     also should preserve all registers except for AX.
  1093.  
  1094.   ---------- isort              Sort Array of Integers
  1095.  
  1096.     push offset array
  1097.     push size
  1098.     call isort
  1099.  
  1100.     This procedure sorts an array of integers of size
  1101.     'size' in ascending order.
  1102.  
  1103.   ---------- lsort              Sort Array of Longs
  1104.  
  1105.     push offset array
  1106.     push size
  1107.     call lsort
  1108.  
  1109.     This procedure sorts an array of long integers of size
  1110.     'size' in ascending order.
  1111.  
  1112.   ---------- ssort              Sort Array of Strings
  1113.  
  1114.     push offset array
  1115.     push size
  1116.     call ssort
  1117.  
  1118.     This procedure sorts an array of strings of size
  1119.     'size' in alphabetical order.
  1120.  
  1121.   ---------- xsort              Sort Array, Generalized
  1122.  
  1123.     push offset array
  1124.     push size
  1125.     push offset cmpfunc
  1126.     call xsort
  1127.  
  1128.     This procedure sorts an array of pointers of size
  1129.     'size'.  This is the generalized sort procedure.
  1130.  
  1131.     This procedure uses a user-defined function.  The
  1132.     function must take two word-sized pointer arguments.
  1133.     It must return the result of the comparison in AX so
  1134.     that a negative value indicates less, a positive value
  1135.     indicates greater, and zero indicates equal, and it
  1136.     also should preserve all registers except for AX.
  1137.  
  1138.  
  1139.   -------------------------------------------------------------
  1140.   ----------------- Miscellaneous Procedures ------------------
  1141.   -------------------------------------------------------------
  1142.  
  1143.   ---------- cputype            Get CPU Type
  1144.  
  1145.     call cputype
  1146.     ; AX = CPU type
  1147.  
  1148.     This procedure returns the CPU type (0 = 8086, 1 = 186,
  1149.     etc.)  It cannot detect SX/DX variations.
  1150.  
  1151.   ---------- fputype            Get FPU Type
  1152.  
  1153.     call fputype
  1154.     ; AX = FPU type
  1155.  
  1156.     This procedure returns the FPU type (0 = 8087, 1 = 187,
  1157.     etc.)  If there is no FPU, -1 is returned.
  1158.  
  1159.   ---------- atexit             Register Exit Function
  1160.  
  1161.     push offset func
  1162.     call atexit
  1163.  
  1164.     This procedure registers a function for calling on exit.
  1165.     If an error occurs, 0 is returned, otherwise a nonzero
  1166.     value is returned.
  1167.  
  1168.   ---------- bitcnt             Count Bits
  1169.  
  1170.     push number
  1171.     call bitcnt
  1172.     ; AX = number of set bits
  1173.  
  1174.     This procedure returns the number of set bits in an
  1175.     integer.
  1176.  
  1177.   ---------- highbit            Find High Bit
  1178.  
  1179.     push number
  1180.     call highbit
  1181.     ; AX = highest bit
  1182.  
  1183.     This procedure returns the positon of the highest set
  1184.     bit in an integer.  -1 is returned if it is zero.
  1185.  
  1186.   ---------- sqrt               Square Root
  1187.  
  1188.     push num_hi
  1189.     push num_lo
  1190.     call sqrt
  1191.     ; AX = result
  1192.  
  1193.     This procedure returns the square root of a long
  1194.     integer.  The result is a normal integer.  This
  1195.     procedure treats all values as unsigned.
  1196.  
  1197.   ---------- exec               Execute Program
  1198.  
  1199.     push offset progname
  1200.     push offset cmdline
  1201.     call exec
  1202.     ; AX = return code
  1203.  
  1204.     This procedure executes another program as a child
  1205.     process, with arguments in 'cmdline'.  If an error
  1206.     occurs, 0 is returned, otherwise a nonzero value
  1207.     is returned.
  1208.  
  1209.   ---------- rand               Random Number
  1210.  
  1211.     push max
  1212.     call rand
  1213.     ; AX = result
  1214.  
  1215.     This procedure returns a random number below 'max'.
  1216.  
  1217.   ---------- srand              Seed Random Numbers
  1218.  
  1219.     call srand
  1220.  
  1221.     This procedure seeds the random number generator with
  1222.     the system clock.
  1223.  
  1224.   ---------- delay              Delay
  1225.  
  1226.     push delaytime
  1227.     call delay
  1228.  
  1229.     This procedure delays for a specified number of
  1230.     milliseconds before returning.
  1231.  
  1232.   ---------- sound              Set Speaker
  1233.  
  1234.     push freq
  1235.     call sound
  1236.  
  1237.     This procedure turns on the speaker at a specified
  1238.     frequency.
  1239.  
  1240.   ---------- nosound            Turn Speaker Off
  1241.  
  1242.   call nosound
  1243.  
  1244.   This procedure turns the speaker off.
  1245.  
  1246.  
  1247.   -------------------------------------------------------------
  1248.   ----------- High-Res Text Mode (90x34) Procedures -----------
  1249.   -------------------------------------------------------------
  1250.  
  1251.   ---------- inittext           Initialize Text System
  1252.  
  1253.     call inittext
  1254.  
  1255.     This procedure initializes the High-Res Text Mode.
  1256.  
  1257.   ---------- closetext          Close Text System
  1258.  
  1259.     call closetext
  1260.  
  1261.     This procedure closes the High-Res Text system, and
  1262.     sets the standard text mode.
  1263.  
  1264.   ---------- clrscr             Clear Screen
  1265.  
  1266.     call clrscr
  1267.  
  1268.     This procedure clears the screen on the current video
  1269.     page.
  1270.  
  1271.   ---------- setwin             Set Window
  1272.  
  1273.     push x1 y1
  1274.     push x2 y2
  1275.     push rel_flag
  1276.     call setwin
  1277.  
  1278.     This procedure sets the clipping window.  'rel_flag'
  1279.     indicates whether coordinates will be relative to the
  1280.     window or not.
  1281.  
  1282.   ---------- clrwin             Clear Window
  1283.  
  1284.     call clrwin
  1285.  
  1286.     This procedure clears the current window.
  1287.  
  1288.   ---------- setpage            Set Video Page
  1289.  
  1290.     push page_num
  1291.     call setpage
  1292.  
  1293.     This procedure sets the current video page.  The page
  1294.     number must be between 0 and 5 (there are six pages).
  1295.  
  1296.   ---------- getpage            Get Video Page
  1297.  
  1298.     call getpage
  1299.     ; AX = current page
  1300.  
  1301.     This procedure returns the current video page.
  1302.  
  1303.   ---------- setcolor           Set Color
  1304.  
  1305.     push color
  1306.     call setcolor
  1307.  
  1308.     This procedure sets the current text color.  The color
  1309.     is a byte, 0XYh, where X is the background color and Y
  1310.     is the foreground color.
  1311.  
  1312.   ---------- getcolor           Get Color
  1313.  
  1314.     call getcolor
  1315.     ; AX = current color
  1316.  
  1317.     This procedure returns the current text color.
  1318.  
  1319.   ---------- box                Draw Box
  1320.  
  1321.     push x1 y1
  1322.     push x2 y2
  1323.     push char
  1324.     call box
  1325.  
  1326.     This procedure draws a box with character 'char'.  The
  1327.     box is clipped to the current window.
  1328.  
  1329.   ---------- sbox               Draw Style Box
  1330.  
  1331.     push x1 y1
  1332.     push x2 y2
  1333.     push style
  1334.     call sbox
  1335.  
  1336.     This procedure draws a style box.  The box is clipped
  1337.     to the current window.  Here is the list of styles:
  1338.  
  1339.     0       Blank
  1340.     1       Single Line
  1341.     2       Double Line
  1342.     3       Single/Double
  1343.     4       Double/Single
  1344.  
  1345.   ---------- fbox               Draw Filled Box
  1346.  
  1347.     push x1 y1
  1348.     push x2 y2
  1349.     push char
  1350.     call fbox
  1351.  
  1352.     This procedure draws a filled box with character 'char'.
  1353.     The box is clipped to the current window.
  1354.  
  1355.   ---------- hline              Draw Horizontal Line
  1356.  
  1357.     push x1 x2
  1358.     push y
  1359.     push char
  1360.     call hline
  1361.  
  1362.     This procedure draws a horizontal line with character
  1363.     'char'.  The line is clipped to the current window.
  1364.  
  1365.   ---------- vline              Draw Vertical Line
  1366.  
  1367.     push y1 y2
  1368.     push x
  1369.     push char
  1370.     call vline
  1371.  
  1372.     This procedure draws a vertical line with character
  1373.     'char'.  The line is clipped to the current window.
  1374.  
  1375.   ---------- hsline             Draw Horizontal Style Line
  1376.  
  1377.     push x1 x2
  1378.     push y
  1379.     push style
  1380.     call hsline
  1381.  
  1382.     This procedure draws a horizontal style line.  The line
  1383.     is clipped to the current window.  See the description
  1384.     for 'sbox' for a list of the styles.
  1385.  
  1386.   ---------- vsline             Draw Vertical Style Line
  1387.  
  1388.     push y1 y2
  1389.     push x
  1390.     push style
  1391.     call vsline
  1392.  
  1393.     This procedure draws a horizontal style line.  The line
  1394.     is clipped to the current window.  See the description
  1395.     for 'sbox' for a list of the styles.
  1396.  
  1397.   ---------- gotoxy             Set Cursor Position
  1398.  
  1399.     push x y
  1400.     call gotoxy
  1401.  
  1402.     This procedure sets the position of the cursor.  It is
  1403.     clipped to the current window.
  1404.  
  1405.   ---------- getx               Get Cursor X
  1406.  
  1407.     call getx
  1408.     ; AX = current X position
  1409.  
  1410.     This procedure returns the X position of the cursor.  If
  1411.     the window relative flag is set, the position will be
  1412.     relative to the current window.
  1413.  
  1414.   ---------- gety               Get Cursor Y
  1415.  
  1416.     call gety
  1417.     ; AX = current Y position
  1418.  
  1419.     This procedure returns the Y position of the cursor.  If
  1420.     the window relative flag is set, the position will be
  1421.     relative to the current window.
  1422.  
  1423.   ---------- setctype           Set Cursor Type
  1424.  
  1425.     push cur_type
  1426.     call setctype
  1427.  
  1428.     This procedure sets the type of the cursor.  The format
  1429.     is: 0XXYYh, where XX is the starting line (0-13) and YY
  1430.     is the ending line (0-13).
  1431.  
  1432.   ---------- getctype           Get Cursor Type
  1433.  
  1434.     call getctype
  1435.     ; AX = cursor type
  1436.  
  1437.     This procedure returns the current cursor type.  The
  1438.     format is: 0XXYYh, where XX is the starting line (0-13)
  1439.     and YY is the ending line (0-13).
  1440.  
  1441.   ---------- setch              Set Character
  1442.  
  1443.     push x y
  1444.     push char
  1445.     call setch
  1446.  
  1447.     This procedure sets the character at (x, y) to 'char'.
  1448.     The output is clipped to the current window.
  1449.  
  1450.   ---------- setat              Set Attribute
  1451.  
  1452.     push x y
  1453.     push attr
  1454.     call setat
  1455.  
  1456.     This procedure sets the attribute at (x, y) to 'attr'.
  1457.     The output is clipped to the current window.
  1458.  
  1459.   ---------- setcha             Set Char & Attr.
  1460.  
  1461.     push x y
  1462.     push char
  1463.     push attr
  1464.     call setcha
  1465.  
  1466.     This procedure sets the character at (x, y) to 'char',
  1467.     and the attribute to 'attr'.  The output is clipped to
  1468.     the current window.
  1469.  
  1470.   ---------- readcha            Read Char & Attr.
  1471.  
  1472.     push x y
  1473.     call readcha
  1474.     ; AL = char, AH = attr
  1475.  
  1476.     This procedure returns the character and attribute
  1477.     at (x, y).
  1478.  
  1479.   ---------- tputs              Put String at (X, Y)
  1480.  
  1481.     push x y
  1482.     push offset string
  1483.     call tputs
  1484.  
  1485.     This procedure prints 'string' at (x, y).  Output is
  1486.     clipped to the current window.  Output will not wrap
  1487.     around lines.  Control characters will be displayed
  1488.     literally.
  1489.  
  1490.   ---------- tprintf            Print Formatted String at (X, Y)
  1491.  
  1492.     push x y
  1493.     push offset fmtstr
  1494.     push offset arglist
  1495.     call tprintf
  1496.  
  1497.     This procedure prints a formatted string at (x, y).
  1498.     It is equivalent to a 'sprintf' followed by 'tputs'.
  1499.     See 'sprintf' and 'tputs' for more information.
  1500.  
  1501.   ---------- getline            Get Line of Text
  1502.  
  1503.     push x y
  1504.     push offset buffer
  1505.     push min
  1506.     push max
  1507.     call getline
  1508.  
  1509.     This procedure inputs a line of text from the user.
  1510.     A field is drawn at (x, y) extending for (max - 1)
  1511.     characters, and the string is input there.  Full
  1512.     editing, i.e. insert/delete, etc., is supported.
  1513.     A string of minimum 'min' and maximum (max - 1)
  1514.     characters will be put into 'buffer'.
  1515.  
  1516.   ---------- setglchar          Set Char for 'getline'
  1517.  
  1518.     push char
  1519.     call setglchar
  1520.  
  1521.     This sets the character used to clear the input field in
  1522.     'getline'.  The default value is a space (20h).  Another
  1523.     useful value is the small bullet (0FAh).
  1524.  
  1525.   ---------- gettext            Get Block of Text
  1526.  
  1527.     push offset buffer
  1528.     push x1 y1
  1529.     push x2 y2
  1530.     call gettext
  1531.  
  1532.     This procedure captures a rectangular block of text into
  1533.     'buffer'.  No clipping is performed.
  1534.  
  1535.   ---------- puttext            Put Block of Text
  1536.  
  1537.     push offset buffer
  1538.     push x1 y1
  1539.     call puttext
  1540.  
  1541.     This procedure displays a rectangular block of text from
  1542.     'buffer' at (x1, y1).  Output is clipped to the current
  1543.     window.
  1544.  
  1545.   ---------- movetext           Move Block of Text
  1546.  
  1547.     push x1 y1
  1548.     push x2 y2
  1549.     push x y
  1550.     call movetext
  1551.  
  1552.     This procedure moves a rectangular block of text from
  1553.     (x1, y1)-(x2, y2) to (x, y).  If the blocks overlap,
  1554.     it will be handled correctly.  No clipping is performed
  1555.     and the window relative flag is ignored.
  1556.  
  1557.   ---------- delline            Delete Line
  1558.  
  1559.     push y
  1560.     call delline
  1561.  
  1562.     This procedure deletes a line (at 'y') from the current
  1563.     window.  All text below the line is scrolled up, and the
  1564.     bottom line is cleared.
  1565.  
  1566.   ---------- insline            Insert Line
  1567.  
  1568.     push y
  1569.     call insline
  1570.  
  1571.     This procedure inserts a line (at 'y') from the current
  1572.     window.  All text below the line is scrolled down, and
  1573.     the inserted line is cleared.
  1574.  
  1575.   ---------- scroll             Scroll Window
  1576.  
  1577.     push dir
  1578.     call scroll
  1579.  
  1580.     This procedure scrolls the current window.  The values
  1581.     for the direction 'dir' are:
  1582.  
  1583.     0       Scroll Up
  1584.     1       Scroll Down
  1585.     2       Scroll Left
  1586.     3       Scroll Right
  1587.  
  1588.  
  1589.   -------------------------------------------------------------
  1590.   -------- High-Res Text Mode (90x34) Mouse Procedures --------
  1591.   -------------------------------------------------------------
  1592.  
  1593.   ---------- minit              Initialize Mouse System
  1594.  
  1595.     call minit
  1596.     ; AX = return code
  1597.  
  1598.     This procedure initializes the High-Res Text Mode
  1599.     Mouse Driver.  If an error occurs or the mouse is
  1600.     not found, 0 is returned, otherwise a nonzero value
  1601.     is returned.
  1602.  
  1603.   ---------- mclose             Close Mouse System
  1604.  
  1605.     call mclose
  1606.  
  1607.     This procedure closes the mouse system.
  1608.  
  1609.   ---------- mshow              Show Mouse Cursor
  1610.  
  1611.     call mshow
  1612.  
  1613.     This procedure displays the mouse cursor on the screen.
  1614.  
  1615.   ---------- mhide              Hide Mouse Cursor
  1616.  
  1617.     call mhide
  1618.  
  1619.     This procedure hides the mouse cursor.
  1620.  
  1621.   ---------- mget               Get Mouse Position
  1622.  
  1623.     call mget
  1624.     ; AX = button status
  1625.     ; BX = mouse X position
  1626.     ; CX = mouse Y position
  1627.  
  1628.     This procedure returns the position and status of the
  1629.     mouse.  The format for the button status is:
  1630.  
  1631.     Bit     Meaning
  1632.  
  1633.      0     Left button
  1634.      1     Right button
  1635.      2     Middle button
  1636.  
  1637.   ---------- mgetdn             Get Mouse Presses
  1638.  
  1639.     push button
  1640.     call mgetdn
  1641.     ; AX = press count
  1642.     ; BX = X position at last press
  1643.     ; CX = Y position at last press
  1644.  
  1645.     This procedure returns the status of a particular mouse
  1646.     button, for presses.  The button values are as follows:
  1647.  
  1648.     0       Left button
  1649.     1       Right button
  1650.     2       Middle button
  1651.  
  1652.   ---------- mgetup             Get Mouse Releases
  1653.  
  1654.     push button
  1655.     call mgetup
  1656.     ; AX = release count
  1657.     ; BX = X position at last release
  1658.     ; CX = Y position at last release
  1659.  
  1660.     This procedure returns the status of a particular mouse
  1661.     button, for releases.  See 'mgetup' for button values.
  1662.  
  1663.  
  1664. 7.  Future additions, bug reporting, etc.
  1665.  
  1666.   Bugs may be reported to the author at:  tjr19@mail.nwlink.com.
  1667.  
  1668.   In the future, a set of wrapper procedures for calling
  1669.   some of the FREELIB routines from 'C' may be provided.
  1670.  
  1671.   This is a list of the routines wanted for future addition:
  1672.  
  1673.   (1) VGA graphics.  (16 AND 256 colors, hopefully integrated,
  1674.         i.e. they do both modes)
  1675.  
  1676.   (2) EMS/XMS/Disk virtual memory manager.  Should be transparent
  1677.         as to which medium is being used.
  1678.  
  1679.   (3) Low-level disk routines (read/write sector, format floppy).
  1680.  
  1681.   (4) Indefinite long arithmetic, 256 bytes at least.
  1682.  
  1683.   (5) Routines to read and write configuration data from the
  1684.         program's executable file.
  1685.  
  1686.   (6) Inter-procedure jumps, like the 'C' setjmp() and longjmp().
  1687.  
  1688.   (7) Sound card interface routines.
  1689.  
  1690.   (8) General data compression.
  1691.  
  1692.   (9) Process management and multitasking.
  1693.  
  1694.   (10) Anything else that might be useful!!!
  1695.  
  1696. ----------------------------------------------------------------------
  1697. ----------------------------------------------------------------------
  1698.